export interface UserEntity {
	account: string
	accountType: number
	name: string
	protocol: 0 | 1 | 2 | 255
	bitrate: number
	bitrateType: number
	portrait32: string
}
export interface RoomEntity {
	id: number
	name: string
	portrait: string
	protocol: 0 | 1 | 2 | 255
	bigProtrait?: string
	regionId?: number
	regionName?: string
}
export interface IUser {
	account: string
	accountType: number
	name: string
	protocol: 0 | 1 | 2 | 255
	bitrate?: number
	bitrateType?: number
	portrait: string
}
export class User implements IUser {
	account: string
	accountType: number
	name: string
	protocol: 0 | 1 | 2 | 255
	bitrate?: number
	bitrateType?: number
	portrait: string
	constructor(user: UserEntity | RoomEntity) {
		if (user.hasOwnProperty('account')) {
			let _user = user as UserEntity
			this.name = _user.name
			this.account = _user.account
			this.accountType = _user.accountType
			this.protocol = _user.protocol
			this.bitrate = _user.bitrate
			this.bitrateType = _user.bitrateType
			this.portrait = _user.portrait32
		} else {
			let room = user as RoomEntity
			this.name = room.name
			this.account = room.id + ''
			this.accountType = 2
			this.protocol = room.protocol
			this.portrait = room.portrait
		}
	}
	get isRoom(): boolean {
		return this.accountType === 2
	}
	/**
	 * 简单级联和模板均通过accountType为10判断
	 */
	get isMeeting(): boolean {
		return this.accountType === 10
	}
}
